app [make_glue] { pf: platform "../platform/main.roc" }

import pf.Types exposing [Types]
import pf.File exposing [File]
import "../../compiler/builtins/bitcode/src/list.zig" as roc_std_list : Str
import "../../compiler/builtins/bitcode/src/str.zig" as roc_std_str : Str
import "../../compiler/builtins/bitcode/src/utils.zig" as roc_std_utils : Str

make_glue : List Types -> Result (List File) Str
make_glue = \types_by_arch ->
    types_by_arch
    |> List.map(convert_types_to_file)
    |> List.concat(static_files)
    |> Ok

## These are always included, and don't depend on the specifics of the app.
static_files : List File
static_files = [
    { name: "list.zig", content: roc_std_list },
    { name: "str.zig", content: roc_std_str },
    { name: "utils.zig", content: roc_std_utils },
]

convert_types_to_file : Types -> File
convert_types_to_file = \_ -> { name: "main.zig", content }

content =
    """
    // ⚠️ GENERATED CODE ⚠️ 
    //
    // This package is generated by the `roc glue` CLI command
    """
